home *** CD-ROM | disk | FTP | other *** search
- /* graphics libraries:
- general library routines
- by Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Oliver Steele, David Van Brink, Chris Yerga
- Copyright 1987 - 1991 Apple Computer, Inc. All rights reserved. */
-
- #include <Memory.h>
- #include "graphics libraries.h"
-
-
- #ifdef MacintoshIncludes
- #endif
-
-
- /*************/
- /* General routines */
- /*************/
-
- void DisposeShapeAt(gxShape *oldShape)
- {
- NilParamReturn(oldShape);
- if (*oldShape) {
- GXDisposeShape(*oldShape);
- *oldShape = nil;
- }
- }
-
- void DisposeStyleAt(gxStyle *oldStyle)
- {
- NilParamReturn(oldStyle);
- if (*oldStyle) {
- GXDisposeStyle(*oldStyle);
- *oldStyle = nil;
- }
- }
-
- void DisposeInkAt(gxInk *oldInk)
- {
- NilParamReturn(oldInk);
- if (*oldInk) {
- GXDisposeInk(*oldInk);
- *oldInk = nil;
- }
- }
-
- void DisposeTransformAt(gxTransform *oldTransform)
- {
- NilParamReturn(oldTransform);
- if (*oldTransform) {
- GXDisposeTransform(*oldTransform);
- *oldTransform = nil;
- }
- }
-
-
- /****************/
- /* operations on shapes */
- /****************/
- static void GetSpaceMapping(gxViewPort port, gxViewDevice device, gxMapping *map)
- {
- if (port)
- GXGetViewPortGlobalMapping(port, map);
- else
- ResetMapping(map);
-
- if( device ) {
- gxMapping temp;
- MapMapping(map, GXGetViewDeviceMapping(device, &temp));
- }
- }
-
- void MapShapeToSpace(gxShape source, gxViewPort port, gxViewDevice device)
- {
- gxMapping map;
-
- GetSpaceMapping(port, device, &map);
- GXMapShape(source, &map);
- }
-
- void MapShapeFromSpace(gxShape source, gxViewPort port, gxViewDevice device)
- {
- gxMapping map;
-
- GetSpaceMapping(port, device, &map);
- InvertMapping(&map, &map);
- GXMapShape(source, &map);
- }
-
- void MapPointToSpace(gxPoint *pt, gxViewPort port, gxViewDevice device)
- {
- gxMapping map;
-
- GetSpaceMapping(port, device, &map);
- MapPoints(&map, 1, pt);
- }
-
- void MapPointFromSpace(gxPoint *pt, gxViewPort port, gxViewDevice device)
- {
- gxMapping map;
-
- GetSpaceMapping(port, device, &map);
- InvertMapping(&map, &map);
- MapPoints(&map, 1, pt);
- }
-